<template>
	<div id="exchange">
		<div class="banner">
		</div>
		<div class="exchange_list">
			<div @click="applyTask(item.id)" v-for="item in taskList" class="task_item">
				<div class="task_img">
					<div class="shade"></div>
	  				<div class="goods_img">
	  					<img src="../../static/img/imgLoading.png"/>
	  					<div class="img_box">
	  						<img :src="item.goodsImage"/>
	  					</div>
	  				</div>
				</div>
  				<div class="task_title">
  					<img :src="getPaltformImg(item.paltform)"/>
  					<p>{{item.taskName}}</p>
  				</div>
				<div class="price">
					<p>¥{{item.price}}</p>
					<p>剩{{item.surplusExchangeNum}}件</p>
				</div>
				<div class="toexchange">
					<p><span>{{item.coinsExchange}}</span>金币</p>
					<input type="button" value="立即兑换"/>
				</div>
  			</div>
		</div>
		<!----------分页--------------->
		<el-pagination
		background
	    @current-change="handleCurrentChange"
	    :current-page.sync="currentPage"
	    :page-size="pageSize"
	    :pager-count="5"
	    layout="prev, pager, next, jumper"
	    :total="total">
		</el-pagination>
	</div>
</template>

<script>
export default {
	name:'exchange',
	data:function(){
		return{
			taskName: '',
			total: 0,//总条数
			pageSize: 15,//每页条数
			currentPage: 1,//当前页码
			taskList:[
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		      	{
		      		Img: '../../static/img/avatar.jpg',
		      		platform: '../../static/img/tb.png',
		      		title: '2018新款短袖女装绿色新款短袖女装绿色',
		      		price: '108.00',
		      		residue: '25',
		      		now: '1080'
		      	},
		    ]
		}
	},
	methods:{
		showCondition:function(){
			var _this = this;
			let postData = _this.$qs.stringify({
				taskName: _this.taskName,
				isCoinsExchange: 1,
				startPage:_this.currentPage,
				pageSize:_this.pageSize,
	        })
			_this.$axios.post('/agent/home/public/showCondition',postData).then(function(res){
			    var data = res.data;
			    if(data.message=="succ"){
			    	data = data.result;
			    	_this.taskList = data.list;
			    	_this.total = data.total;
			    	console.log(data);
			    }else{
			    	_this.$alert("2",data.result);
			    }
//		    	_this.taskList = data;
			}).catch(function (error) {
			    console.log(error);
			});
		},
		//-----------分页页码改变------------
	    handleCurrentChange:function(val) {
	        this.currentPage=val;
	        this.showCondition();
	    },
	    getPaltformImg:function(obj){
			if(obj==1){
				return "./../static/img/tb.png";
			}else if(obj==2){
				return "./../static/img/tm.png";
			}else if(obj==3){
				return "./../static/img/jd.png";
			}
		},
		applyTask:function(obj){
			this.$router.push({path:'/home/detail?taskId='+obj})
		},
	},
	created:function(){
		this.showCondition();
		if(this.$route.query.taskName){
			this.taskName = this.$route.query.taskName
		}
	},
	watch:{
		$route(){
			this.taskName = this.$route.query.taskName;
			this.showCondition();
		}
	}
}
</script>
<style>
/*-----------分页器样式------------*/
.el-pagination{
	text-align: center;
	margin-top: 20px;
}
.el-pagination.is-background .el-pager li:not(.disabled).active{
	background-color: #FF464E;
}
.el-pagination.is-background .el-pager li:not(.active):hover{
	color: #FF464E;
}
</style>
<style scoped>
.banner{
	width: 100%;
	height: 94px;
	background: url('../../static/img/home-21.png') no-repeat center;
	background-size: auto 100%;
	/*background-color: #dddddd;*/
	display: flex;
	justify-content: center;
	overflow: hidden;
}
/*-------任务列表----------*/
.exchange_list{
	width: 1230px;
	margin: 0 auto;
	margin-top: 20px;
	display: flex;
	flex-wrap: wrap;
}
.exchange_list .task_item:nth-child(5n){
	margin-right: 0;
}
/*----------单个任务-------------*/
.task_item{
	width: 238px;
	background-color: #fff;
	padding: 20px;
	box-sizing: border-box;
	margin-right: 10px;
	margin-bottom: 10px;
	border: 1px solid transparent;
	cursor: pointer;
}
.task_item:hover{
	border: 1px solid #FF464E;
}
.task_item:hover .shade{
	display: block;
}
.task_img{
	position: relative;
}
.task_img .shade{
	width: 100%;
	height: 100%;
	position: absolute;
	top: 0;
	left: 0;
	background-color: rgba(255,255,255,0.2);
	display: none;
}
.task_img img{
	width: 100%;
	display: block;
}
.goods_img{
	position: relative;
	width: 100%;
}
.goods_img>img{
	width: 100%;
	display: block;
}
.goods_img .img_box{
	position: absolute;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	overflow: hidden;
	display: flex;
	align-items: center;
}
.goods_img .img_box img{
	width: 100%;
	display: block;
}
.task_title{
	margin-top: 5px;
	display: flex;
	align-items: flex-end;
}
.task_title img{
	display: block;
	height: 20px;
	margin-right: 5px;
}
.task_title p{
	width: calc(100% - 25px);
	height: 20px;
	line-height: 28px;
	color: #5E5E5E;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.price{
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 10px;
}
.price p:first-child{
	color: #9F9F9F;
	text-decoration: line-through;
}
.price p:last-child{
	color: #5E5E5E;
}
.toexchange{
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	margin-top: 10px;
}
.toexchange p{
	color: #FF464E;
	font-size: 12px;
}
.toexchange p span{
	font-size: 22px;
	font-weight: bold;
	margin-right: 3px;
}
.toexchange input{
	border: 1px solid #FF464E;
	color: #FF464E;
	width: 86px;
	height: 28px;
	background-color: #fff;
	border-radius: 3px;
	font-size: 12px;
}
/*------------分页-----------*/
.paging{
	display: flex;
	align-items: center;
	justify-content: center;
	margin-top: 10px;
	margin-bottom: 30px;
}
.last,.next,.paging_list li{
	width: 30px;
	height: 30px;
	border: 1px solid #E6E6E6;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #9F9F9F;
	box-sizing: border-box;
	cursor: pointer;
}
.last img,.next img{
	height: 18px;
	display: block;
}
.next,.paging_list li{
	margin-left: 8px;
}
.paging_list{
	display: flex;
}
.topaging{
	display: flex;
	align-items: center;
	margin-left: 8px;
}
.topaging p{
	color: #9F9F9F;
}
.topaging input[type='text']{
	width: 30px;
	height: 30px;
	text-align: center;
	border: 1px solid #E6E6E6;
	margin: 0 5px;
	background-color: transparent;
	color: #5E5E5E;
}
.topaging input[type='button']{
	height: 30px;
	width: 60px;
	border: 1px solid #E6E6E6;
	background-color: transparent;
	margin-left: 8px;
	color: #5E5E5E;
}
span.paging_active,li.paging_active{
	background-color: #FF464E;
	color: #FFFFFF;
	border: none;
}
</style>
